//
//  LookPigInfoView.m
//  PigMarket
//
//  Created by mac on 2019/7/2.
//  Copyright © 2019 felix.pigmarket.oc. All rights reserved.
//

#import "LookPigInfoView.h"

@interface LookPigInfoView ()

/**
 横线
 */
@property (nonatomic , strong) UIView *hLine;



/**
 竖灰线
 */
@property (nonatomic , strong) UIView *sLine;

@end
@implementation LookPigInfoView

#pragma mark - init method
- (instancetype)init
{
    self = [super init];
    if (self) {
        [self initView];
        [self initLayout];
    }
    return self;
}

- (void)initView {
    // 添加子控件
    [self addSubview:self.headImg];
    [self addSubview:self.titleLab];
    [self addSubview:self.numLab];
    [self addSubview:self.supervisePeopleNumLab];
    [self addSubview:self.toSaleBtn];
    [self addSubview:self.hLine];
    [self addSubview:self.foodBookBtn];
    [self addSubview:self.sLine];
    [self addSubview:self.recordBtn];

}

- (void)initLayout {
    // 布局子控件
    [self.headImg mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(15);
        make.top.mas_equalTo(15);
        make.size.mas_equalTo(50);
    }];
    [self.titleLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(self.headImg.mas_right).offset(10);
        make.top.mas_equalTo(15);
        make.height.mas_equalTo(22);
    }];
    [self.numLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(self.titleLab.mas_right).offset(5);
        make.height.mas_equalTo(18);
        make.top.mas_equalTo(15);
    }];
    [self.supervisePeopleNumLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(self.headImg.mas_right).offset(10);
        make.top.mas_equalTo(self.titleLab.mas_bottom).offset(7);
        make.height.mas_equalTo(17);
    }];
    [self.toSaleBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.mas_equalTo(-15);
        make.top.mas_equalTo(26);
        make.size.mas_equalTo(CGSizeMake(56, 27));
    }];
    [self.hLine mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.mas_equalTo(0);
        make.top.mas_equalTo(self.headImg.mas_bottom).offset(15);
        make.height.mas_equalTo(1);
    }];
    [self.foodBookBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(self.hLine.mas_bottom).offset(14);
        make.centerX.mas_equalTo(self.mas_centerX).multipliedBy(1.5);
        make.height.mas_equalTo(40);
        make.bottom.mas_equalTo(-14);
    }];
    [self.sLine mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.mas_equalTo(self.mas_centerX);
        make.centerY.mas_equalTo(self.foodBookBtn.mas_centerY);
        make.size.mas_equalTo(CGSizeMake(2, 26));
    }];
    [self.recordBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(self.hLine.mas_bottom).offset(14);
        make.height.mas_equalTo(40);
        make.bottom.mas_equalTo(-14);
        make.centerX.mas_equalTo(self.mas_centerX).multipliedBy(0.5);
    }];
}

#pragma mark - getter and setter
- (UIImageView *)headImg {
    if (!_headImg) {
        _headImg = [[UIImageView alloc] init];
    }
    return _headImg;
}
- (UILabel *)titleLab {
    if (!_titleLab) {
        _titleLab = [[UILabel alloc] init];
        _titleLab.textColor = [UIColor textBlackColor];
        _titleLab.font = [UIFont boldSystemFontOfSize:16];
    }
    return _titleLab;
}
- (UILabel *)numLab {
    if (!_numLab) {
        _numLab = [[UILabel alloc] init];
        _numLab.textColor = [UIColor colorWithHexString:@"#F1935F"];
        _numLab.font = [UIFont systemFontOfSize:10];
        _numLab.backgroundColor = [UIColor colorWithHexString:@"#FEF6EE"];
        _numLab.layer.cornerRadius = 3;
        _numLab.layer.masksToBounds = YES;
    }
    return _numLab;
}
- (UILabel *)supervisePeopleNumLab {
    if (!_supervisePeopleNumLab) {
        _supervisePeopleNumLab = [[UILabel alloc] init];
        _supervisePeopleNumLab.textColor = [UIColor colorWithHexString:@"#999999"];
        _supervisePeopleNumLab.font = [UIFont systemFontOfSize:12];
    }
    return _supervisePeopleNumLab;
}
- (UIButton *)toSaleBtn {
    if (!_toSaleBtn) {
        _toSaleBtn = [UIButton buttonWithType:UIButtonTypeCustom];
        [_toSaleBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
        _toSaleBtn.titleLabel.font = [UIFont systemFontOfSize:12];
        [_toSaleBtn setBackgroundImage:[UIImage imageNamed:@"meat_cart_pay_right"] forState:UIControlStateNormal];
    }
    return _toSaleBtn;
}
- (UIView *)hLine {
    if (!_hLine) {
        _hLine = [[UIView alloc] init];
        _hLine.backgroundColor = [UIColor colorWithHexString:@"#EAEAEA"];
    }
    return _hLine;
}
- (UIView *)sLine {
    if (!_sLine) {
        _sLine = [[UIView alloc] init];
        _sLine.backgroundColor = [UIColor colorWithHexString:@"#EAEAEA"];
    }
    return _sLine;
}
- (UIButton *)foodBookBtn {
    if (!_foodBookBtn) {
        _foodBookBtn = [UIButton buttonWithType:UIButtonTypeCustom];
        [_foodBookBtn setTitle:@"  它的食谱" forState:UIControlStateNormal];
        [_foodBookBtn setTitleColor:[UIColor colorWithHexString:@"#666666"] forState:UIControlStateNormal];
        _foodBookBtn.titleLabel.font = [UIFont systemFontOfSize:17];
        [_foodBookBtn setImage:[UIImage imageNamed:@"adopt_adoptdetail_foodbook"] forState:UIControlStateNormal];
    }
    return _foodBookBtn;
}
- (UIButton *)recordBtn {
    if (!_recordBtn) {
        _recordBtn = [UIButton buttonWithType:UIButtonTypeCustom];
        [_recordBtn setTitle:@"  仔猪档案" forState:UIControlStateNormal];
        [_recordBtn setTitleColor:[UIColor colorWithHexString:@"#666666"] forState:UIControlStateNormal];
        _recordBtn.titleLabel.font = [UIFont systemFontOfSize:17];
        [_recordBtn setImage:[UIImage imageNamed:@"adopted_look_record"] forState:UIControlStateNormal];
        
    }
    return _recordBtn;
}
@end
